﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function showMessage() {
            var fname = document.getElementById("firstName").value;
            var lname = document.getElementById("lastName").value;
            var time = new Date();
            if (checkEmail()) {
                alert(fname + " " + lname + " " + time);
            }
        }
        function checkEmail() {
            var email = document.getElementById("email");
            var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
            if (!filter.test(email.value)) {
                return false;
            }
            else {
                return true;
            }
        }
    </script>
</head>
<body>
<form action="HTMLPage.htm">
    First name
    <input type="text" id="firstName" />
    <br />
    Last name
    <input type="text" id="lastName" />
    <br />
    e-mail
    <input type="text" id="email" />
    <br />
    <input type="button" value="Check e-mail" onclick="javascript: checkEmail()" />
    <input type="button" value="Show message" onclick="javascript: showMessage()" />
</form>

</body>
</html>
